package com.jumi.microservice.core.exception;


import cn.hutool.core.util.StrUtil;
import com.jumi.microservice.common.base.dto.ResponseResult;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class MyExceptionHandler {

    @ExceptionHandler(value = BaseException.class)
	@ResponseBody
	public ResponseResult exceptionHandler(BaseException e){
		String module = e.getModule();
		String errMsg = e.getDefaultMessage();
		if(StrUtil.isNotEmpty(module)){
			errMsg= StrUtil.format("{}--:{}",module,errMsg);
		}
		return ResponseResult.error(errMsg);
    }
}
